using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;
using System.Drawing;

using Microsoft.Win32;

using TD.SandDock;

using SBPweb.Themes.Windows;
using SBPweb.Themes.Windows.Skins;
using SBPweb.Modules.Modularity;

namespace SBPweb.Controls.Windows.Docking
{
	public class DockManager : TD.SandDock.SandDockManager, SBPweb.Themes.Windows.Skins.ISkinnable, ILayoutProvider 
	{
		private bool mUseDefaultSkin;
		private Skin mSkin;

		public DockManager()
			: base()
		{
			
		}

		public void Invalidate()
		{
				if (this.DockSystemContainer.Parent != null)
				{
					this.DockSystemContainer.Parent.Invalidate(true);
				}
				else
				{
					this.DockSystemContainer.Invalidate(true);
				}
		}

		public void SaveToRegistry(RegistryKey PersistenceKey)
		{
			string persistenceString = this.GetLayout();
			PersistenceKey.SetValue("DockingLayoutXML", persistenceString, RegistryValueKind.String);
		}

		public void RestoreFromRegistry(RegistryKey PersistenceKey)
		{
			string persistenceString = PersistenceKey.GetValue("DockingLayoutXML") as string;
			if (!string.IsNullOrEmpty(persistenceString))
				this.SetLayout(persistenceString);
		}

		#region ISkinnable Members

		/// <summary>
		/// Use default skin?
		/// </summary>
		[Category("Look && feel")]
		public bool UseDefaultSkin
		{
			get
			{
				return mUseDefaultSkin;
			}
			set
			{
				mUseDefaultSkin = value;
			}
		}

		/// <summary>
		/// Used skin
		/// </summary>
		[Category("Look && feel")]
		public Skin Skin
		{
			get
			{
				if (this.UseDefaultSkin)
				{
					return DefaultLookAndFeel.Skin;
				}

				return mSkin;
			}
			set
			{
				mSkin = value;
			}
		}

		#endregion

	}
}
